<?php

namespace App\Console\Commands\Corn;

use App\Models\ReceivePaymentBody;
use App\Models\ReceivePaymentHeader;
use Carbon\Carbon;
use GuzzleHttp\Client;
use Illuminate\Console\Command;

// 获取维涛数据
class CheckWtData extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'corn:check-wt';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '检测维涛数据是否有问题';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    protected $guzzleOptions = [];

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        // 拿到今天的数据
        $docCodes = ReceivePaymentHeader::query()
            ->where('DocDate', '=', Carbon::now()->toDateString())
            ->get("DocCode");

        $docCodes = $docCodes->toArray();

        $Rowid = ReceivePaymentBody::query()
            ->whereIn('DocCode', $docCodes)
            ->get("Rowid")
            ->toArray();

        $headerCount = count($docCodes);
        $bodyCount = count($Rowid);
        $client = new Client([]);

        $client->post("http://yun.bohua2000.com/Home/BohuaReport/zfglDefaultCheckAndSendDataByEventDay", [
            "Rowids" => $Rowid,
            "DocCodes" => $docCodes,
            "bodyCount" => $bodyCount,
            "headerCount" => $headerCount
        ]);

//        $client = new Client(POST, URL，[
//        'body' => json_encode($value, JSON_UNESCAPED_UNICODE),
//'headers' => ['content-type' => 'application/json']
//])
    }
}
